import request from '@/config/axios'

// 商品分类 VO
export interface CategoryVO {
  id: number // 编号
  parentId: number // 父分类编号
  name: string // 名称
  thumb: string // 缩略图
  weight: number // 排序
  blindStatus: boolean
  status: boolean
}

// 商品分类 API
export const CategoryApi = {
  // 查询商品分类分页
  getCategoryPage: async (params: any) => {
    return await request.get({ url: `/worker/category/page`, params })
  },

  // 查询商品分类详情
  getCategory: async (id: number) => {
    return await request.get({ url: `/worker/category/get?id=` + id })
  },
  
  // 获得商品分类列表
  getCategoryList: async (params: any) => {
    return await request.get({ url: '/worker/category/list', params })
  },

  // 新增商品分类
  createCategory: async (data: CategoryVO) => {
    return await request.post({ url: `/worker/category/create`, data })
  },

  // 修改商品分类
  updateCategory: async (data: CategoryVO) => {
    return await request.put({ url: `/worker/category/update`, data })
  },
  
  // 修改分类盲盒状态
  updateCategoryBlindStatus: async (id: number, blindStatus: boolean) => {
    const data = {
      id,
      blindStatus
    }
    return await request.put({ url: '/worker/category/update-blindStatus', data: data })
  },
  
  // 修改分类状态
  updateCategoryStatus: async (id: number, status: boolean) => {
    const data = {
      id,
      status
    }
    return await request.put({ url: '/worker/category/update-status', data: data })
  },

  // 删除商品分类
  deleteCategory: async (id: number) => {
    return await request.delete({ url: `/worker/category/delete?id=` + id })
  },

  // 导出商品分类 Excel
  exportCategory: async (params) => {
    return await request.download({ url: `/worker/category/export-excel`, params })
  },
}